import { createApp } from 'vue'
import { createPinia } from 'pinia'
import piniaPersist from 'pinia-plugin-persistedstate'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'
import './styles/global.css'

import App from './App.vue'
import router from './router'

const app = createApp(App)

const pinia = createPinia()
pinia.use(piniaPersist)

app.use(pinia)
app.use(router)
app.use(ElementPlus)

// 初始化暗黑模式（从持久化的 app store 读取）
import { useAppStore } from './stores/app'
const appStore = useAppStore()
if (appStore.dark) {
  document.documentElement.classList.add('dark')
}

app.mount('#app')
